﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;

using PasswordGenerator;

namespace TestWinClient
{
    public partial class frmMain : Form
    {

        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            //Clipboard.Clear();
        }

        private void btnGenerate_Click(object sender, EventArgs e)
        {
            List<PasswordRequirement> req = new List<PasswordRequirement>();
            
            if (chkLower.Checked)
                req.Add(new LowerCase());
            if (chkUpper.Checked)
                req.Add(new UpperCase());
            if (chkNumber.Checked)
                req.Add(new Numeric());
            if (chkSpecial.Checked)
                req.Add(new SpecialCharacter());
            
            if (req.Count == 0)
                MessageBox.Show("Must choose 1 requirement", "Requirement Needed", MessageBoxButtons.OK);
            else
            {
                req.Add(new PasswordLength(Convert.ToInt32(nudLength.Value)));

                txtGeneratedPassword.Text = PasswordManager.GeneratePassword(req);

                txtPasswordLength.Text = txtGeneratedPassword.Text.Length.ToString();
            }
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtGeneratedPassword.Text))
                Clipboard.SetData(DataFormats.UnicodeText, txtGeneratedPassword.Text);
        }
    }
}
